package org.example.new_hbps_backend_reconstruction.config;

import org.example.new_hbps_backend_reconstruction.handler.CalibrationWebSocketHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * @author 丁利军
 * @date 2025年10月31日 14:34
 * @description 与心永设备通信的配置类
 */

@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(new CalibrationWebSocketHandler(), "/api/ext/websocket/{token}")
                .setAllowedOrigins("*");
    }
}
